package com.ztools.wx.handler;

import com.ztools.wx.async.WxMpAsyncTasks;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author:seeTools
 * @Date: 2023/4/9  12:53
 * @Version 1.0
 */
@Component
public class UnsubscribeHandler extends AbstractHandler {

    @Resource
    private WxMpAsyncTasks wxMpAsyncTasks;

    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map, WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
        String openId = wxMpXmlMessage.getFromUser();
        logger.info("取消关注用户 OPENID: " + openId);
        // 会员取消关注业务处理逻辑
//        wxMpAsyncTasks.unsubscribe(openId);
        return null;
    }

}
